package com.yjhb.android.sbz.mvp.publishtask;

import com.yjhb.android.sbz.entity.TaskInfo;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;
import com.jojo.android.zxlib.tool.ZxLogTool;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2021/1/8 10:09
 * 获取发布某用户的所有任务
 */
public class PublishTaskListPresenter extends ConventionPresenter<PublishTaskListView> {
    private final String TAG = "PublishTaskListPresenter";

    @Override
    protected void onDestroy() {

    }

    public PublishTaskListPresenter(PublishTaskListView publishTaskListView) {
        super(publishTaskListView);
    }


    public void getPublishTaskList(Integer userId, int size, int current) {
        if (userId == null) {
            ZxLogTool.err(new Throwable("pubHistory id is null!!!!"));
            return;
        }
        if (model == null){
            return;
        }
        HttpTool.request(model.publishTaskList(userId, size, current), new HttpObserver<List<TaskInfo>>() {
            @Override
            public void onResult(List<TaskInfo> data) {
                if (view != null) {
                    if (current == 1) {
                        view.refresh(data);
                    } else {
                        view.load(data);
                    }
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }

//    public void getPublishTaskList(Integer userId, int size, int current) {
//        getPublishTaskList(userId, size, current);
//    }

}
